package tests.common;

import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;


public class Prepare {
	InitialContext context;
	private EntityManager em;
	
	public Prepare(){
		try {
			this.context = new InitialContext();
			EntityManagerFactory emf=Persistence.createEntityManagerFactory("TicketboxJPA");
			em=emf.createEntityManager();
		} catch (NamingException e) {
			e.printStackTrace();
		}
	}
	
	public void initDB(){
		em.getTransaction().begin();
		em.createQuery("TRUNCATE TABLE user u").executeUpdate();
		em.getTransaction().commit();
	}
}
